#!/usr/bin/env python

##  flamingo - 2D Game Engine
##  Copyright (C) 2009 Bradley Zeis
##
##  This program is free software: you can redistribute it and/or modify
##  it under the terms of the GNU General Public License as published by
##  the Free Software Foundation, either version 3 of the License, or
##  (at your option) any later version.
##
##  This program is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU General Public License for more details.
##
##  You should have received a copy of the GNU General Public License
##  along with this program.  If not, see <http://www.gnu.org/licenses/>.
##
##  Bradley Zeis
##  bradzeis@gmail.com

import unittest
import pickle
import flamingo

class TestScreen(unittest.TestCase):
    def setUp(self):
        self.p = flamingo.screen.Screen((0, 0), 800, 600)

        self.bad = [[1, 2, 3],
                    [{'foo': 'bar'}, "meow!", (1, 2), ["3","4"]],
                    [(1,), 2, 3]]

    def testAccess(self):
        self.assertEqual(self.p.center, (400, 300))
        self.assertEqual(self.p.local_rect, ((0, 0), (800, 0), (800, 600), (0, 600)))
        self.p.height = 400
        self.assertEqual(self.p.local_rect.height, 600)
        self.assertTrue(self.p.local_rect.enabled(flamingo.constants.POLYGON_AXIS_ALIGNED))
        self.assertRaises(AttributeError, flamingo.screen.Screen.disable,
                          self.p.local_rect, flamingo.constants.POLYGON_AXIS_ALIGNED)

    def testBad(self):
        for b in self.bad:
            self.assertRaises(TypeError, flamingo.flmath.Rect, b)


##-------- Test Suite
testscreen = unittest.TestLoader().loadTestsFromTestCase(TestScreen)

testsuite = unittest.TestSuite((testscreen))

if __name__ == "__main__":
    unittest.TextTestRunner(verbosity=2).run(testsuite)
